module(..., package.seeall)
-- This Screen is the introductory Screen (i.e., starting menu)
-- This is the main function. It MUST return a display.newGroup(); find out why
function new()
	local localGroup = display.newGroup()

	-- Background TODO find a background image
	local background = display.newImage("genericbg.png",0,0,true)
	localGroup:insert(background)

	-- Title
	local title = display.newText("Contrast Balls", 0, 0, native.systemFontBold, 24)
	title:setTextColor(255, 255, 255) -- white
	title.x = 240
	title.y = 20
	localGroup:insert(title)

	-- Buttons TODO get the play button
	local bt01 = display.newImage("button-play.png")
	
	local function bt01t ( event )
		-- once the button is pressed, it triggers a scene which leads to the puzzle
		if event.phase == "ended" then
			director:changeScene("scene1", "moveFromRight")
		end
	end

	-- when bt01 is touched, it triggers function bt01t
	bt01:addEventListener("touch",bt01t)
	bt01.x = 245
	bt01.y = 100
	localGroup:insert(bt01)

	-- Credits TODO get the credits button
	local bt02 = display.newImage("button-credits.png")
	local function bt02t (event )
		if event.phase == "ended" then
			director:changeScene("credits","moveFromRight")
		end
	end

	bt02:addEventListener("touch",bt02t)
	bt02.x = 245
	bt02.y = 200
	localGroup:insert(bt02)

	-- MUST return a display.newGroup() [object?]
	return localGroup
end
